package com.hhm.huo.controller;


import com.hhm.huo.entity.Result;
import com.hhm.huo.entity.User;
import com.hhm.huo.service.IUserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author 安安
 * @since 2022-05-26
 */
@RestController
@RequestMapping("/user")
public class UserController {
//    @Autowired
//    IUserService userService;
//    @RequestMapping("loginOK")
//    public Result loginOK(HttpServletRequest request){
//        Object principal = SecurityContextHolder.getContext().getAuthentication().getPrincipal();// 获取当前登录信息
//        if (principal instanceof UserDetails) {//判断principal是不是UserDetails类型
//            UserDetails userDetails = (UserDetails) principal;
//            User loginUser =  userService.getByName(userDetails.getUsername());
//            //存入session作用域 保存到redis中
//            request.getSession().setAttribute("LOGIN_USER",loginUser);
//            return new Result(loginUser);
//        }
//        return new Result(100,"登录失败!密码错误");
//    }
//    @RequestMapping("register")
//    public Result register(String username,String password,String password1){
//        if (!password.equals(password1)){
//            return new Result(201,"");
//        }else {
//            User user = new User();
//            user.setUsername(username);
//            user.setPassword(password);
//            userService.save(user);
//            return new Result(200,"");
//        }
//    }
//    @RequestMapping("logoutOK")
//    public Result logoutOK() {
//        return new Result(200);
//    }
}
